<?php

class stockController {
	
	function __construct() {
	}
	public function index() {		
		if( !Tools::isAjax() ) return;
		session_start();		
		$model = new stock;
		$data = $model->select();
		echo json_encode( $data );
	}
	
	public function crossindex() {		
		if( !Tools::isAjax() ) return;
		session_start();		
		$model = new stock;
		$data = $model->crossindex();
		echo json_encode( $data );
	}
	
	public function find() {		
		if( !Tools::isAjax() ) return;
		session_start();		
		$model = new stock;
		$data = $model->find();
		echo json_encode( $data );
	}
	
	public function insert() {		
		if( !Tools::isAjax() ) return;
		session_start();
		$model = new stock;
		$data = $model->insert();
		echo json_encode( $data );
	}
	
	public function update() {		
		if( !Tools::isAjax() ) return;
		session_start();
		$model = new stock;
		$data = $model->update();
		echo json_encode( $data );
	}
	
	public function delete() {		
		if( !Tools::isAjax() ) return;
		session_start();
		$model = new stock;
		$data = $model->delete();
		echo json_encode( $data );
	}
	
	public function retire() {		
		if( !Tools::isAjax() ) return;
		session_start();
		$model = new stock;
		$data = $model->retire();
		echo json_encode( $data );
	}
	
	public function unretire() {		
		if( !Tools::isAjax() ) return;
		session_start();
		$model = new stock;
		$data = $model->unretire();
		echo json_encode( $data );
	}
	
	public function jsload() {		
		if( !Tools::isAjax() ) return;
		if( isset($_REQUEST['sc']) && ($sc = trim( strip_tags($_REQUEST['sc']) ) ) != '') {
			switch( $sc ) {
			case 'stock': App::me()->js_load('stock.js'); break;
			case 'crossstock': App::me()->js_load('crossstock.js'); break;			
			}
		}
	}	
	
}
?>